
package cn.edu.scau.cmi.hombio.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.Calendar;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import org.codehaus.jackson.annotate.JsonIgnore;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllTasks", query = "select myTask from Task myTask"),
		@NamedQuery(name = "findTaskByCreateTime", query = "select myTask from Task myTask where myTask.createTime = ?1"),
		@NamedQuery(name = "findTaskByEndTime", query = "select myTask from Task myTask where myTask.endTime = ?1"),
		@NamedQuery(name = "findTaskById", query = "select myTask from Task myTask where myTask.id = ?1"),
		@NamedQuery(name = "findTaskByMemo", query = "select myTask from Task myTask where myTask.memo = ?1"),
		@NamedQuery(name = "findTaskByMemoContaining", query = "select myTask from Task myTask where myTask.memo like ?1"),
		@NamedQuery(name = "findTaskByPrimaryKey", query = "select myTask from Task myTask where myTask.id = ?1"),
		@NamedQuery(name = "findTaskByStartTime", query = "select myTask from Task myTask where myTask.startTime = ?1"),
		@NamedQuery(name = "findTaskByTaskNumber", query = "select myTask from Task myTask where myTask.taskNumber = ?1"),
		@NamedQuery(name = "findTaskByTaskNumberContaining", query = "select myTask from Task myTask where myTask.taskNumber like ?1") })

@Table(catalog = "pig", name = "task")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "pigRs/cn/edu/scau/cmi/hombio/domain", name = "Task")
@XmlRootElement(namespace = "pigRs/cn/edu/scau/cmi/hombio/domain")
public class Task implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "Id", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@Id @GeneratedValue
	@XmlElement
	Integer id;
	/**
	 */

	@Column(name = "TaskNumber", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String taskNumber;
	/**
	* ���񷢲�ʱ��
	* 
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "CreateTime", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	Calendar createTime;
	/**
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "StartTime", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	Calendar startTime;
	/**
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "EndTime")
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	Calendar endTime;
	/**
	 */

	@Column(name = "Memo")
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String memo;

	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "CustomerId", referencedColumnName = "Id") })
	@XmlTransient
	Customer customer;
	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "TaskStatusId", referencedColumnName = "Id", nullable = false) })
	@XmlTransient
	TaskStatusType taskStatusType;
	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "TaskTypeId", referencedColumnName = "Id", nullable = false) })
	@XmlTransient
	TaskType taskType;
	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "CreateEmployeeId", referencedColumnName = "Id", nullable = false) })
	@XmlTransient
	Employee employee;
	/**
	 */
	@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.Sale> sales;
	/**
	 */
	@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.Feed> feeds;
	/**
	 */
	@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.TaskPig> taskPigs;
	/**
	 */
	@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.TaskEmployee> taskEmployees;
	/**
	 */
	@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.MedicineTake> medicineTakes;
	/**
	 */
	@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.Inspection> inspections;
	/**
	 */
	@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.Except> excepts;
	/**
	 */
	@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.TaskManage> taskManages;
	/**
	 */
	@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.Prevention> preventions;
	/**
	 */
	@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.TaskIntervalCycle> taskIntervalCycles;
	/**
	 */
	@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.CureTaskCourse> cureTaskCourses;
	/**
	 */
	@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.SaleTaskQuality> saleTaskQualities;
	/**
	 */
	@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.TaskPrevention> taskPreventions;
	/**
	 */
	@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.Transfer> transfers;
	/**
	 */
	@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.FodderTake> fodderTakes;
	/**
	 */
	@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.TaskPighouse> taskPighouses;
	/**
	 */
	@OneToMany(mappedBy = "task", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.TaskPigsty> taskPigsties;

	/**
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 */
	public Integer getId() {
		return this.id;
	}

	/**
	 */
	public void setTaskNumber(String taskNumber) {
		this.taskNumber = taskNumber;
	}

	/**
	 */
	public String getTaskNumber() {
		return this.taskNumber;
	}

	/**
	* ���񷢲�ʱ��
	* 
	 */
	public void setCreateTime(Calendar createTime) {
		this.createTime = createTime;
	}

	/**
	* ���񷢲�ʱ��
	* 
	 */
	public Calendar getCreateTime() {
		return this.createTime;
	}

	/**
	 */
	public void setStartTime(Calendar startTime) {
		this.startTime = startTime;
	}

	/**
	 */
	public Calendar getStartTime() {
		return this.startTime;
	}

	/**
	 */
	public void setEndTime(Calendar endTime) {
		this.endTime = endTime;
	}

	/**
	 */
	public Calendar getEndTime() {
		return this.endTime;
	}

	/**
	 */
	public void setMemo(String memo) {
		this.memo = memo;
	}

	/**
	 */
	public String getMemo() {
		return this.memo;
	}

	/**
	 */
	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	/**
	 */
	@JsonIgnore
	public Customer getCustomer() {
		return customer;
	}

	/**
	 */
	public void setTaskStatusType(TaskStatusType taskStatusType) {
		this.taskStatusType = taskStatusType;
	}

	/**
	 */
	@JsonIgnore
	public TaskStatusType getTaskStatusType() {
		return taskStatusType;
	}

	/**
	 */
	public void setTaskType(TaskType taskType) {
		this.taskType = taskType;
	}

	/**
	 */
	@JsonIgnore
	public TaskType getTaskType() {
		return taskType;
	}

	/**
	 */
	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	/**
	 */
	@JsonIgnore
	public Employee getEmployee() {
		return employee;
	}

	/**
	 */
	public void setSales(Set<Sale> sales) {
		this.sales = sales;
	}

	/**
	 */
	@JsonIgnore
	public Set<Sale> getSales() {
		if (sales == null) {
			sales = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Sale>();
		}
		return sales;
	}

	/**
	 */
	public void setFeeds(Set<Feed> feeds) {
		this.feeds = feeds;
	}

	/**
	 */
	@JsonIgnore
	public Set<Feed> getFeeds() {
		if (feeds == null) {
			feeds = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Feed>();
		}
		return feeds;
	}

	/**
	 */
	public void setTaskPigs(Set<TaskPig> taskPigs) {
		this.taskPigs = taskPigs;
	}

	/**
	 */
	@JsonIgnore
	public Set<TaskPig> getTaskPigs() {
		if (taskPigs == null) {
			taskPigs = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskPig>();
		}
		return taskPigs;
	}

	/**
	 */
	public void setTaskEmployees(Set<TaskEmployee> taskEmployees) {
		this.taskEmployees = taskEmployees;
	}

	/**
	 */
	@JsonIgnore
	public Set<TaskEmployee> getTaskEmployees() {
		if (taskEmployees == null) {
			taskEmployees = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskEmployee>();
		}
		return taskEmployees;
	}

	/**
	 */
	public void setMedicineTakes(Set<MedicineTake> medicineTakes) {
		this.medicineTakes = medicineTakes;
	}

	/**
	 */
	@JsonIgnore
	public Set<MedicineTake> getMedicineTakes() {
		if (medicineTakes == null) {
			medicineTakes = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.MedicineTake>();
		}
		return medicineTakes;
	}

	/**
	 */
	public void setInspections(Set<Inspection> inspections) {
		this.inspections = inspections;
	}

	/**
	 */
	@JsonIgnore
	public Set<Inspection> getInspections() {
		if (inspections == null) {
			inspections = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Inspection>();
		}
		return inspections;
	}

	/**
	 */
	public void setExcepts(Set<Except> excepts) {
		this.excepts = excepts;
	}

	/**
	 */
	@JsonIgnore
	public Set<Except> getExcepts() {
		if (excepts == null) {
			excepts = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Except>();
		}
		return excepts;
	}

	/**
	 */
	public void setTaskManages(Set<TaskManage> taskManages) {
		this.taskManages = taskManages;
	}

	/**
	 */
	@JsonIgnore
	public Set<TaskManage> getTaskManages() {
		if (taskManages == null) {
			taskManages = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskManage>();
		}
		return taskManages;
	}

	/**
	 */
	public void setPreventions(Set<Prevention> preventions) {
		this.preventions = preventions;
	}

	/**
	 */
	@JsonIgnore
	public Set<Prevention> getPreventions() {
		if (preventions == null) {
			preventions = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Prevention>();
		}
		return preventions;
	}

	/**
	 */
	public void setTaskIntervalCycles(Set<TaskIntervalCycle> taskIntervalCycles) {
		this.taskIntervalCycles = taskIntervalCycles;
	}

	/**
	 */
	@JsonIgnore
	public Set<TaskIntervalCycle> getTaskIntervalCycles() {
		if (taskIntervalCycles == null) {
			taskIntervalCycles = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskIntervalCycle>();
		}
		return taskIntervalCycles;
	}

	/**
	 */
	public void setCureTaskCourses(Set<CureTaskCourse> cureTaskCourses) {
		this.cureTaskCourses = cureTaskCourses;
	}

	/**
	 */
	@JsonIgnore
	public Set<CureTaskCourse> getCureTaskCourses() {
		if (cureTaskCourses == null) {
			cureTaskCourses = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.CureTaskCourse>();
		}
		return cureTaskCourses;
	}

	/**
	 */
	public void setSaleTaskQualities(Set<SaleTaskQuality> saleTaskQualities) {
		this.saleTaskQualities = saleTaskQualities;
	}

	/**
	 */
	@JsonIgnore
	public Set<SaleTaskQuality> getSaleTaskQualities() {
		if (saleTaskQualities == null) {
			saleTaskQualities = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.SaleTaskQuality>();
		}
		return saleTaskQualities;
	}

	/**
	 */
	public void setTaskPreventions(Set<TaskPrevention> taskPreventions) {
		this.taskPreventions = taskPreventions;
	}

	/**
	 */
	@JsonIgnore
	public Set<TaskPrevention> getTaskPreventions() {
		if (taskPreventions == null) {
			taskPreventions = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskPrevention>();
		}
		return taskPreventions;
	}

	/**
	 */
	public void setTransfers(Set<Transfer> transfers) {
		this.transfers = transfers;
	}

	/**
	 */
	@JsonIgnore
	public Set<Transfer> getTransfers() {
		if (transfers == null) {
			transfers = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Transfer>();
		}
		return transfers;
	}

	/**
	 */
	public void setFodderTakes(Set<FodderTake> fodderTakes) {
		this.fodderTakes = fodderTakes;
	}

	/**
	 */
	@JsonIgnore
	public Set<FodderTake> getFodderTakes() {
		if (fodderTakes == null) {
			fodderTakes = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.FodderTake>();
		}
		return fodderTakes;
	}

	/**
	 */
	public void setTaskPighouses(Set<TaskPighouse> taskPighouses) {
		this.taskPighouses = taskPighouses;
	}

	/**
	 */
	@JsonIgnore
	public Set<TaskPighouse> getTaskPighouses() {
		if (taskPighouses == null) {
			taskPighouses = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskPighouse>();
		}
		return taskPighouses;
	}

	/**
	 */
	public void setTaskPigsties(Set<TaskPigsty> taskPigsties) {
		this.taskPigsties = taskPigsties;
	}

	/**
	 */
	@JsonIgnore
	public Set<TaskPigsty> getTaskPigsties() {
		if (taskPigsties == null) {
			taskPigsties = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskPigsty>();
		}
		return taskPigsties;
	}

	/**
	 */
	public Task() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(Task that) {
		setId(that.getId());
		setTaskNumber(that.getTaskNumber());
		setCreateTime(that.getCreateTime());
		setStartTime(that.getStartTime());
		setEndTime(that.getEndTime());
		setMemo(that.getMemo());
		setCustomer(that.getCustomer());
		setTaskStatusType(that.getTaskStatusType());
		setTaskType(that.getTaskType());
		setEmployee(that.getEmployee());
		setSales(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Sale>(that.getSales()));
		setFeeds(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Feed>(that.getFeeds()));
		setTaskPigs(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskPig>(that.getTaskPigs()));
		setTaskEmployees(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskEmployee>(that.getTaskEmployees()));
		setMedicineTakes(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.MedicineTake>(that.getMedicineTakes()));
		setInspections(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Inspection>(that.getInspections()));
		setExcepts(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Except>(that.getExcepts()));
		setTaskManages(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskManage>(that.getTaskManages()));
		setPreventions(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Prevention>(that.getPreventions()));
		setTaskIntervalCycles(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskIntervalCycle>(that.getTaskIntervalCycles()));
		setCureTaskCourses(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.CureTaskCourse>(that.getCureTaskCourses()));
		setSaleTaskQualities(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.SaleTaskQuality>(that.getSaleTaskQualities()));
		setTaskPreventions(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskPrevention>(that.getTaskPreventions()));
		setTransfers(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.Transfer>(that.getTransfers()));
		setFodderTakes(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.FodderTake>(that.getFodderTakes()));
		setTaskPighouses(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskPighouse>(that.getTaskPighouses()));
		setTaskPigsties(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskPigsty>(that.getTaskPigsties()));
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("id=[").append(id).append("] ");
		buffer.append("taskNumber=[").append(taskNumber).append("] ");
		buffer.append("createTime=[").append(createTime).append("] ");
		buffer.append("startTime=[").append(startTime).append("] ");
		buffer.append("endTime=[").append(endTime).append("] ");
		buffer.append("memo=[").append(memo).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof Task))
			return false;
		Task equalCheck = (Task) obj;
		if ((id == null && equalCheck.id != null) || (id != null && equalCheck.id == null))
			return false;
		if (id != null && !id.equals(equalCheck.id))
			return false;
		return true;
	}
}
